package com.demo;

/**
 * <p>
 * <code>Demo02</code>
 * </p>
 *
 * @author junbao3
 * TODO
 * @date 2023-06-27 15:35
 * Copyright (C) 2021 IFlyTek. All rights reserved.
 */
public class Demo02 {


    public static void main(String[] args) {
        A xpp = new A();
        xpp.num=10;
        A xp = new A();
        xp.num=2;
        A x = new A();
        x.num=5;

        xpp.left=xp;
        xp.parent=xpp;

        xp.right= x;
        x.parent=xp;

        method(x=xp);

        System.out.println(xpp);
        xpp = (xp = x.parent) == null ? null : xp.parent;
        System.out.println(xpp);
        System.out.println(xp);
        System.out.println(x);
        System.out.println(x.parent);
    }

    private static void method(A p) {
        A r = p.right;
        A pp = r.parent = p.parent;
        pp.left=r;
        r.left=p;
        p.parent=r;
    }
}


class A{
    int num;
    A parent;
    A left;
    A right;

    @Override
    public String toString() {
        return "A{" +
                "num=" + num +
                '}';
    }
}
